package com.qianniu.napi.admin.service.impl;

import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.baomidou.mybatisplus.plugins.Page;
import com.qianniu.napi.admin.entity.CutpriceHelp;
import com.qianniu.napi.admin.entity.CutpriceOpen;
import com.qianniu.napi.admin.mapper.CutpriceHelpMapper;
import com.qianniu.napi.admin.mapper.CutpriceOpenMapper;
import com.qianniu.napi.admin.mapper.OrderMapper;
import com.qianniu.napi.admin.service.ICutpriceOpenService;
import com.baomidou.mybatisplus.service.impl.ServiceImpl;
import com.qianniu.napi.common.util.ObjectUtil;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * <p>
 * 发起砍价活动 服务实现类
 * </p>
 *
 * @author chenxuebin
 * @since 2018-07-14
 */
@Service
public class CutpriceOpenServiceImpl extends ServiceImpl<CutpriceOpenMapper, CutpriceOpen> implements ICutpriceOpenService {


    private static final Logger logger = LoggerFactory.getLogger(CutpriceOpenServiceImpl.class);

    @Autowired
    private CutpriceOpenMapper cutpriceOpenMapper;
    @Autowired
    private CutpriceHelpMapper cutpriceHelpMapper;

    public List<CutpriceOpen> getMyCutpriceOpen(Page page, Long uid){

        int total = cutpriceHelpMapper.selectCount(new EntityWrapper<CutpriceHelp>().eq("uid",uid));
        page.setTotal(total);

        Map<String,Object> map = new HashMap<String,Object>();
        map.put("uid",uid);
        map.put("size",page.getSize());
        map.put("skip",page.getOffset());

        List<CutpriceOpen> list = cutpriceOpenMapper.selectMyCutpriceOpen(map);
        return list;
    }

}
